package com.osmino.contacts.groups.dragndrop;

import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.osmino.contacts.R;
import com.osmino.core.style.IStyleableView;
import com.osmino.core.style.Style;

public class DragAndDropView extends RelativeLayout implements IStyleableView{
	
	private final boolean DBG = true;
	private final int LAYOUT = R.layout.drag_n_drop;
	private static final int DND_ICON_IV = R.id.groups_d_n_d_icon;
	private static final int DND_COUNT_TV = R.id.groups_d_n_d_how_much;//
	private DragInfo mInfo;
	
	public DragAndDropView(Activity activity){
		super(activity);
		activity.getLayoutInflater().inflate(LAYOUT, this);
	}
	
	public DragAndDropView(Activity activity, DragInfo info) {
		super(activity);
		this.mInfo = info;
		activity.getLayoutInflater().inflate(LAYOUT, this);
		setInfo(info);
	}
	
	public void clearInfo() {
		TextView tvCount = (TextView) findViewById(DND_COUNT_TV);
		ImageView ivPic = (ImageView)findViewById(DND_ICON_IV);
		tvCount.setText("");
		ivPic.setBackgroundDrawable(null);
	}

	public void setInfo(DragInfo info) {
		clearInfo();
		TextView tvCount = (TextView) findViewById(DND_COUNT_TV);
		ImageView ivPic = (ImageView)findViewById(DND_ICON_IV);
		if(info.count!=null)
			tvCount.setText(info.count);
		if(info.icon!=null)
			ivPic.setBackgroundDrawable(new BitmapDrawable(info.icon));
	}

	@Override
	public void setStyle(Style style) {
	}

	public DragInfo getInfo() {
		return mInfo;
	}
}